let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n135,
  i =
    (this && this.__extends) ||
    ((_n135 = function n(t, e) {
      return (_n135 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
    function (t, e) {
      function o() {
        this.constructor = t;
      }
      _n135(t, e),
        (t.prototype =
          null === e
            ? Object.create(e)
            : ((o.prototype = e.prototype), new o()));
    });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.OperationItem = void 0);
var r = t('UIComponent'),
  a = t('ComUtils'),
  s = t('CivilizationMrg'),
  c = t('SoundMrg'),
  l = t('ResMrg'),
  u = t('MathUtils'),
  h = t('LevelCom'),
  p = t('MergeMrg'),
  f = (function (t) {
    function e() {
      return (null !== t && t.apply(this, arguments)) || this;
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this),
          (this.type = 0),
          (this._imgFrame = a.default.getComponent(
            cc.Sprite,
            this.view,
            'ItemNode/imgIcon/imgFrame'
          )),
          (this._imgIcon = a.default.getComponent(
            cc.Sprite,
            this.view,
            'ItemNode/imgIcon/imgIcon'
          )),
          (this._imgYuan = a.default.getComponent(
            cc.Sprite,
            this.view,
            'ItemNode/imgIcon/imgYuan'
          )),
          (this._button = this.view.getComponent(cc.Button)),
          (this._itemNode = a.default.getNode(this.view, 'ItemNode')),
          (this._ndItemNode = a.default.getNode(this.view, 'ItemNode/imgIcon')),
          (this._lockNode = a.default.getNode(this.view, 'lockNode')),
          (this._button.interactable = this.enabled),
          (this._level = new h.LevelCom(
            a.default.getNode(this.view, 'ItemNode/imgIcon/imgYuan/Level')
          )),
          (this.view.active = !0),
          this.loadDataIcon();
      }),
      Object.defineProperty(e.prototype, 'data', {
        get: function get() {
          return this._data;
        },
        set: function set(t) {
          this._data != t &&
            ((this._data = t), this.refresh(), this.onDataChanged());
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onDataChanged = function () {}),
      (e.prototype.refresh = function () {
        this.loadDataIcon();
      }),
      (e.prototype.toTop = function (t) {
        if (t) {
          if (this.view.parent != p.MergeMrg.view) {
            var e = p.MergeMrg.view.convertToNodeSpaceAR(
              this.view.convertToWorldSpaceAR(cc.v2(0, 0))
            );
            (this._viewParent = this.view.parent),
              (this.view.parent = p.MergeMrg.view),
              (this.view.x = e.x),
              (this.view.y = e.y);
          }
        } else
          this._viewParent &&
            ((e = this._viewParent.convertToNodeSpaceAR(
              this.view.convertToWorldSpaceAR(cc.v2(0, 0))
            )),
            (this.view.parent = this._viewParent),
            (this.view.x = e.x),
            (this.view.y = e.y),
            (this._viewParent = null));
      }),
      (e.prototype.onEnabled = function (t) {
        this._button.interactable = t;
      }),
      (e.prototype.onDrag = function (t) {
        if (this._isDraging) {
          var e = p.MergeMrg.view.convertToNodeSpaceAR(t);
          this._ndItemNode.parent != p.MergeMrg.view &&
            this._ndItemNode.setParent(p.MergeMrg.view),
            (this._ndItemNode.x = e.x),
            (this._ndItemNode.y = e.y);
        }
      }),
      (e.prototype.reset = function () {
        this._ndItemNode.stopAllActions();
        var t = this.view.convertToWorldSpaceAR(new cc.Vec2(0, 0));
        (t = p.MergeMrg.view.convertToNodeSpaceAR(t)),
          cc
            .tween(this._ndItemNode)
            .to(0.1, {
              x: t.x,
              y: t.y
            })
            .call(this.onStopDrag, this)
            .start();
      }),
      (e.prototype.startDrag = function () {
        this._isDraging = !0;
      }),
      (e.prototype.stopDrag = function () {
        this.onStopDrag();
      }),
      (e.prototype.onStopDrag = function () {
        (this._isDraging = !1),
          (this._ndItemNode.parent = this._itemNode),
          this._ndItemNode.setPosition(0, 0),
          c.SoundMrg.click();
      }),
      (e.prototype.lineToItem = function (t) {
        if (this.data) {
          if (
            this._lineToItem != t &&
            ((this._lineToItem = t), !this._isToItem)
          ) {
            if (t) {
              var e = t.view.getPosition(),
                o = Math.atan2(e.y - this.view.y, e.x - this.view.x),
                n = 10 * Math.cos(o),
                i = 10 * Math.sin(o);
              return (
                this._ndItemNode.stopAllActions(),
                void cc
                  .tween(this._ndItemNode)
                  .to(0.5, {
                    x: n,
                    y: i
                  })
                  .to(0.5, {
                    x: 0,
                    y: 0
                  })
                  .union()
                  .repeatForever()
                  .start()
              );
            }
            this._ndItemNode.stopAllActions(),
              cc
                .tween(this._ndItemNode)
                .to(0.1, {
                  x: 0,
                  y: 0
                })
                .start();
          }
        } else
          (this._lineToItem = null),
            (this._ndItemNode.x = 0),
            (this._ndItemNode.y = 0);
      }),
      (e.prototype.setDragData = function (t, e, o) {
        var n = this,
          i = this,
          r = p.MergeMrg.view.convertToNodeSpaceAR(
            this.view.convertToWorldSpaceAR(cc.v2(0, 0))
          );
        (this._ndItemNode.parent = p.MergeMrg.view),
          (this._ndItemNode.x = r.x),
          (this._ndItemNode.y = r.y),
          (this._ndItemNode.scale = 2),
          (this._ndItemNode.opacity = 128),
          (this.data = t),
          cc
            .tween(this._ndItemNode)
            .to(
              0.3,
              {
                scale: 1,
                opacity: 255
              },
              {
                easing: 'elasticOut'
              }
            )
            .call(function () {
              (i._ndItemNode.parent = i._itemNode),
                (i._ndItemNode.x = 0),
                (i._ndItemNode.y = 0),
                e.call(o, n);
            })
            .start();
      }),
      Object.defineProperty(e.prototype, 'isDraging', {
        get: function get() {
          return this._isDraging;
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onDestroy = function () {
        (this._data = null), t.prototype.onDestroy.call(this);
      }),
      (e.prototype.loadDataIcon = function () {
        if (this._data) {
          if (this._data.type <= 3) {
            var t = u.default.clamp(
              this._data.level - s.CivilizationMrg.ins.id + 1,
              1,
              6
            );
            l.ResMrg.loadSpriteByAtlas(
              this._imgFrame,
              'Atlas/Battle',
              'frame' + this.data.type + t
            ),
              (this._imgFrame.node.active = !0),
              l.ResMrg.loadSpriteByAtlas(
                this._imgIcon,
                'Atlas/Battle',
                this._data.icon
              ),
              (this._imgIcon.node.scale = 0.5 + (t / 6) * 0.5),
              (this._imgIcon.node.active = !0),
              l.ResMrg.loadSpriteByAtlas(
                this._imgYuan,
                'Atlas/Battle',
                'yuan' + this.data.type + t
              ),
              (this._imgYuan.node.active = !0),
              (this._level.level = this._data.level);
          } else
            l.ResMrg.loadSpriteByAtlas(
              this._imgIcon,
              'Atlas/Battle',
              this._data.icon
            ),
              (this._imgIcon.node.y = 0),
              (this._imgIcon.node.scale = 1),
              (this._imgIcon.node.active = !0),
              (this._imgYuan.node.active = !1),
              (this._imgFrame.spriteFrame = null),
              (this._imgFrame.node.active = !1);
        } else
          (this._imgFrame.spriteFrame = null),
            (this._imgFrame.node.active = !1),
            (this._imgIcon.spriteFrame = null),
            (this._imgIcon.node.active = !1),
            (this._imgYuan.node.active = !1);
      }),
      e
    );
  })(r.UIComponent);
(o.OperationItem = f), console.log('end');
module.exports = e.exports;
